<?php
include "../default.php";
include "../config.php";
$server = BASEURL;
$date = date('Y-m-d');

$dom = new DomDocument('1.0','UTF-8');
$urlset = $dom->appendChild($dom->createElement("urlset"));
$urlset->setAttribute('xmlns','http://www.sitemaps.org/schemas/sitemap/0.9');

// ** general page **//

//home
$url = $urlset->appendChild($dom->createElement("url"));
$loc = $url->appendChild($dom->createElement("loc"));
$loc->appendChild($dom->createTextNode($server));
$mod = $url->appendChild($dom->createElement("lastmod"));
$mod->appendChild($dom->createTextNode($date));
$prio = $url->appendChild($dom->createElement("priority"));
$prio->appendChild($dom->createTextNode(1.0));

// about us
$url = $urlset->appendChild($dom->createElement("url"));
$loc = $url->appendChild($dom->createElement("loc"));
$loc->appendChild($dom->createTextNode($server."about_us.html"));
$mod = $url->appendChild($dom->createElement("lastmod"));
$mod->appendChild($dom->createTextNode($date));
$prio = $url->appendChild($dom->createElement("priority"));
$prio->appendChild($dom->createTextNode(0.5));

// contact
$url = $urlset->appendChild($dom->createElement("url"));
$loc = $url->appendChild($dom->createElement("loc"));
$loc->appendChild($dom->createTextNode($server."contact.html"));
$mod = $url->appendChild($dom->createElement("lastmod"));
$mod->appendChild($dom->createTextNode($date));
$prio = $url->appendChild($dom->createElement("priority"));
$prio->appendChild($dom->createTextNode(0.5));

// Generate Hotels Sitemap
$query = mysql_query("SELECT * FROM hotels");

while ($data = @mysql_fetch_array($query)) {
	$url = $urlset->appendChild($dom->createElement("url"));
	$loc = $url->appendChild($dom->createElement("loc"));
	$loc->appendChild($dom->createTextNode($server.$data['hotel_slug'].".html"));
	$mod = $url->appendChild($dom->createElement("lastmod"));
	$mod->appendChild($dom->createTextNode($date));
	$prio = $url->appendChild($dom->createElement("priority"));
	$prio->appendChild($dom->createTextNode(0.8));
}

$dom->save("../sitemap.xml");

?>